package com.dingwen.treasure.business.service.impl;

import cn.hutool.core.util.StrUtil;
import com.dingwen.treasure.base.enums.ActivityStatusEnum;
import com.dingwen.treasure.business.service.ActivityStatusService;
import com.dingwen.treasure.mybatisplus.service.ActivityInfoService;
import com.dingwen.treasure.core.exception.ActivityStatusChangeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 　ReviewActivityStatusServiceImpl： 审核
 * 　@author dingwen
 * 　@date 2022/5/15$
 */
@Service
@Slf4j
public class ReviewActivityStatusServiceImpl implements ActivityStatusService {

    /**
     * activityStatusService
     */
    @Resource
    private  ActivityInfoService activityStatusService;

    /**
     * 变更状态的类型
     *
     */
    @Override
    public String getStatusType() {
        return ActivityStatusEnum.REVIEWING.toString();
    }

    /**
     * 编辑
     *
     * @param activityId     活动id
     * @param activityStatus 活动状态
     * @return {@link Boolean}
     */
    @Override
    public Boolean editing(Long activityId, ActivityStatusEnum activityStatus) {
        String message = "activityId：{},审核状态下不能进行编辑";
        throw new ActivityStatusChangeException(StrUtil.format(message, activityId));
    }

    /**
     * 审核
     *
     * @param activityId     活动id
     * @param activityStatus 活动状态
     * @return {@link Boolean}
     */
    @Override
    public Boolean reviewing(Long activityId, ActivityStatusEnum activityStatus) {
        String message = "activityId：{},已处于审核状态中";
        throw new ActivityStatusChangeException(StrUtil.format(message, activityId));
    }

    /**
     * 拒绝
     *
     * @param activityId     活动id
     * @param activityStatus 活动状态
     * @return {@link Boolean}
     */
    @Override
    public Boolean rejecting(Long activityId, ActivityStatusEnum activityStatus) {
        return activityStatusService.changeStatus(ActivityStatusEnum.REVIEWING, ActivityStatusEnum.REJECTING, activityId);
    }

    /**
     * 通过
     *
     * @param activityId     活动id
     * @param activityStatus 活动状态
     * @return {@link Boolean}
     */
    @Override
    public Boolean passing(Long activityId, ActivityStatusEnum activityStatus) {
        return activityStatusService.changeStatus(ActivityStatusEnum.REVIEWING, ActivityStatusEnum.PASSING, activityId);
    }

    /**
     * 开启
     *
     * @param activityId     活动id
     * @param activityStatus 活动状态
     * @return {@link Boolean}
     */
    @Override
    public Boolean opening(Long activityId, ActivityStatusEnum activityStatus) {
        String message = "activityId：{},仍处于审核状态中的活动不允许进行开启";
        throw new ActivityStatusChangeException(StrUtil.format(message, activityId));
    }

    /**
     * 关闭
     *
     * @param activityId     活动id
     * @param activityStatus 活动状态
     * @return {@link Boolean}
     */
    @Override
    public Boolean closing(Long activityId, ActivityStatusEnum activityStatus) {
        String message = "activityId：{},仍处于审核状态中的活动未开启不需要进行关闭";
        throw new ActivityStatusChangeException(StrUtil.format(message, activityId));
    }
}
